﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MSWMDMLib;
using FireZone.NativeWMDMInteface;
using System.Runtime.InteropServices;

namespace FireZone
{
    internal static class WMDMStorageExtensions
    {
        public static object GetStorageMetadataByName(this IWMDMStorage wmdmStorage, string metadataName)
        {
            IWMDMMetaData wmdmMetadata;
            ((IWMDMStorage3)wmdmStorage).GetMetadata(out wmdmMetadata);
            try
            {
                return wmdmMetadata.GetMetadataByName(metadataName);
            }
            finally
            {
                Marshal.ReleaseComObject(wmdmMetadata);
            }
        }
        public static string GetStorageName(this IWMDMStorage wmdmStorage)
        {
            StringBuilder strName = new StringBuilder(1024);
            wmdmStorage.GetName(strName, (uint)strName.Capacity);
            return strName.ToString();
        }
    }
}
